package com.common.utils;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.TaskStore;
import com.service.TaskStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.*;

@Component
public class RedisUtils {

    @Autowired
    private TaskStoreService taskStoreService;

    /**
     * 暂时模拟缓存
     */
    public static Map<Integer,String> nameMap=new HashMap<>();

    @PostConstruct
    public void initMap(){
        Wrapper<TaskStore> wr=new EntityWrapper<>();
        List<TaskStore> taskStores = taskStoreService.selectList(wr);
        if(!CollectionUtils.isEmpty(taskStores)){
            for (TaskStore taskStore : taskStores) {
                nameMap.put(taskStore.getId(),taskStore.getName());
            }
        }
    }


    public static void main(String[] args) {
        Collection  c=new ArrayList();
        c.add("java");
        c.add("mysql");
        c.add(100);//没有指定泛型的时候不报错

        Collection<String>  d=new ArrayList();
        d.add("java");
        d.add("mysql");
//        d.add(100);//指定泛型的时候报错

    }
}
